$(function(){
	
	let loadData = function(current=1){
		$.post(
			"/rotation-img.do",
			function(data){
				formatData(data);
			},"json"
		);
		
	}
	
	let firstOl=$("ol");
//	let firstLi=$("ol:first-child");
	let img=$(".item");
	let imgParent=img.parent();

	let firstLi  = firstOl.children().remove();
	let imgDiv  = imgParent.children().remove();
	let formatData = function(list){
		firstOl.empty();
		imgParent.empty();
		$.each(list,function(i,item){
			console.info(i);
			let l = firstLi.clone().appendTo(firstOl);
			let img = imgDiv.clone().appendTo(imgParent);
			
			if(i==0){
				l.attr("class","active");
				img.attr("class","item active");
			}
			l.attr("data-slide-to",i);
			img.find("img").attr("src",item.imgSrc);
			img.find("a").attr("href",item.imgHref);
		});
	}
	loadData();
	
	
});